/*     */ package com.zimbra.soap;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.ByteUtil;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.httpclient.URLUtil;
/*     */ import com.zimbra.cs.servlet.ZimbraServlet;
/*     */ import com.zimbra.soap.util.WsdlGenerator;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WsdlServlet
/*     */   extends ZimbraServlet
/*     */ {
/*     */   private static final long serialVersionUID = -2727046288266393825L;
/*     */   
/*     */   public void init()
/*     */     throws ServletException
/*     */   {
/*  50 */     LogFactory.init();
/*     */     
/*  52 */     String name = getServletName();
/*  53 */     ZimbraLog.soap.info("Servlet " + name + " starting up");
/*  54 */     super.init();
/*     */   }
/*     */   
/*     */   public void destroy()
/*     */   {
/*  59 */     String name = getServletName();
/*  60 */     ZimbraLog.soap.info("Servlet " + name + " shutting down");
/*  61 */     super.destroy();
/*     */   }
/*     */   
/*     */   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
/*     */   {
/*     */     
/*     */     try
/*     */     {
/*  69 */       addRemoteIpToLoggingContext(req);
/*  70 */       String pathInfo = req.getPathInfo();
/*  71 */       if ((pathInfo == null) || (pathInfo.length() == 0)) {
/*  72 */         resp.sendError(400);
/*     */       }
/*     */       else {
/*  75 */         if (pathInfo.startsWith("/")) {
/*  76 */           pathInfo = pathInfo.substring(1);
/*     */         }
/*  78 */         ZimbraLog.soap.debug("WSDL SERVLET Received a GET pathInfo=" + pathInfo);
/*  79 */         if (pathInfo.matches("^[a-zA-Z]+\\.xsd$")) {
/*  80 */           InputStream is = JaxbUtil.class.getResourceAsStream(pathInfo);
/*  81 */           if (is == null) {
/*  82 */             resp.sendError(404); return;
/*     */           }
/*     */           
/*  85 */           resp.setContentType("text/xml");
/*  86 */           ByteUtil.copy(is, true, resp.getOutputStream(), false);
/*     */         }
/*  88 */         else if (!WsdlGenerator.handleRequestForWsdl(pathInfo, resp.getOutputStream(), getSoapURL(), getSoapAdminURL()))
/*     */         {
/*  90 */           resp.sendError(404);
/*     */         }
/*     */       }
/*     */     } finally {
/*  94 */       ZimbraLog.clearContext();
/*     */     }
/*     */   }
/*     */   
/*     */   private static String getSoapAdminURL() {
/*     */     try {
/* 100 */       return URLUtil.getAdminURL(Provisioning.getInstance().getLocalServer());
/*     */     } catch (ServiceException e) {}
/* 102 */     return "https://localhost:7071/service/admin/soap";
/*     */   }
/*     */   
/*     */   private static String getSoapURL()
/*     */   {
/*     */     try {
/* 108 */       return URLUtil.getServiceURL(Provisioning.getInstance().getLocalServer(), "/service/soap/", true);
/*     */     }
/*     */     catch (ServiceException e) {}
/* 111 */     return "http://localhost:7070/service/soap";
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/soap/WsdlServlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */